package club.cearnach.api.service.impl;

import club.cearnach.api.dao.IRoleDao;
import club.cearnach.entity.Role;
import club.cearnach.api.service.IRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

/**
 * @author 阮胜
 * @date 2018/5/23 18:09
 */
@Service
@Transactional(rollbackFor = Exception.class)
@Slf4j
public class RoleServiceImpl implements IRoleService {
    private final IRoleDao roleDao;

    public RoleServiceImpl(IRoleDao roleDao) {
        this.roleDao = roleDao;
    }

    @Override
    public Optional<Role> findByName(String name) {
        return roleDao.findByName(name);
    }
    @Override
    public List<Role> findAll() {
        return roleDao.findAll();
    }

    @Override
    public Optional<Role> findById(Integer id) {
        return roleDao.findById(id);
    }

}
